<?php
session_start();

include 'objects/User.inc';
if (isset($_SESSION['user'])) {
    $user = unserialize($_SESSION['user']);
    if ($user->isLogged()) {
        header("Location: menu.php");
        exit();
    }
} else {
    $user = new User();
}
?><!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Login</title>
        <link rel="stylesheet" href="css/index.css">
    </head>
    <body>
        <div id="section">
            <img src="img/logo.png" width="400px;"><br>
            <p><?php
                echo $user->msg;
                $user->msg = "";
                $_SESSION['user'] = serialize($user);
                ?>
            </p>
            <form action="login.php" method="post">
                <fieldset>
                    <legend><img src="img/login.png">&nbsp;Iniciar Sesion</legend>
                    <label><img src="img/user.png">&nbsp;Usuario:</label><input type="text" name="usuario"><br>
                    <label><img src="img/pass.png">&nbsp;Contrase&ntilde;a:</label><input type="password" name="clave"><br>
                    <input type="submit" value="Entrar">
                </fieldset>
            </form>
        </div>
    </body>
</html>
